package com.atguigu.gull.gmall.gateway.properties;

import com.atguigu.gmall.common.utils.RsaUtils;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;
import java.io.File;
import java.security.PublicKey;

@Configuration
@ConfigurationProperties(prefix = "auth.jwt")
@Data
@Slf4j
public class JwtProperties {
    private String pubKeyFilePath;
    private String cookieTokenName;

    private PublicKey publicKey;

    /**
     * 初始化公钥
     */
    @PostConstruct
    public void init() throws Exception {
        try {
            publicKey = RsaUtils.getPublicKey(pubKeyFilePath);
        } catch (Exception e) {
            log.info("初始化公钥失败");
        }

    }

}
